﻿// SLTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>
#include "SLT_timer.h"

#include <thread>
//#include <windows.h>
#include <chrono>
#include <list>

struct timer_event
{
    SLT_elapseTimer  m_start;
    int64_t elapseTime = -1;
    uint64_t th;
};


std::list< timer_event*>  evetnList;

static void time_out(SLT_timer_CallBackType _type, SLT_TIMER_HANDLE timerid, void* userData)
{
    timer_event* pevent = (timer_event*)userData;
    pevent->elapseTime = pevent->m_start.elapseMs();
    //printf("\n diff:%d\n", duration.count());
    evetnList.push_back(pevent);
}

int tool_timer_test_main()
{

    for (int i = 0; i < 10000; i++) {
        timer_event* pevent = new timer_event;
        pevent->m_start.start();
		//Sleep(100);
	   // std::this_thread::sleep_for(std::chrono::milliseconds(100));
		//auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - pevent->start);
		//printf("\n diff:%d\n", duration.count());
        SLT_setTimer(pevent->th,1000,false, time_out, pevent);
    }

    SLT_sleep(5000);

    for (auto titem : evetnList) {
		printf("\n diff:%d\n", (int)titem->elapseTime);
    }
    return 0;
}

